<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *项目管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$manage_op=array('start','off');
if(in_array($_RQ['op'],$manage_op)){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择事件！','error');
	}
}
$tabs=array(
			array('op'=>'list','title'=>'信息列表'),
			array('op'=>'edit','title'=>'添加信息'),
);
	$return['sex']=array('0'=>'男','1'=>'女','2'=>'不限');
	$return['position']=array('0'=>'男','1'=>'女','2'=>'不限');
	$return['pay']=array('0'=>'面议','1'=>'1-1000','2'=>'1000-2000','3'=>'2000-3000','4'=>'3000-5000','5'=>'5000-8000','6'=>'8000-10000','7'=>'1000-15000','8'=>'15000以上');
	$return['educationid']=array('1'=>'初中及以下','2'=>'高中、中专','3'=>'大专','4'=>'本科','5'=>'研究生及以上');
	$return['timesid']=array('1'=>'一年以下','2'=>'一至三年','3'=>'三到五年','4'=>'五年以上');
	$return['isbuycar']=array('0'=>'出售','1'=>'求购');
	$return['isbuy']=array('0'=>'求购','1'=>'出售','3'=>'转让');
	$return['classifyid']=array('0'=>'打听事','1'=>'寻物启事','2'=>'其他');
	$return['classifyid']=array('1'=>'电脑办公','2'=>'家具家电','3'=>'手机','4'=>'文体户外','5'=>'服饰配饰','6'=>'儿童母婴','7'=>'美容保健','8'=>'数码产品','9'=>'居家日常','10'=>'其他');
	$return['lev']=array(array('id'=>'0','title'=>'轿车'),array('id'=>'1','title'=>'SUV'),array('id'=>'2','title'=>'MPV'),array('id'=>'3','title'=>'微面'),array('id'=>'4','title'=>'皮卡'),array('id'=>'5','title'=>'电动车'),array('id'=>'6','title'=>'其他'));

if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$type = intval($_RQ['id']);
	if($type){
		$this->session('type',$type);
	}else{
		$type=$this->session('type');
	}
	$modetype=pdo_getcolumn('jy_sort_item_type',array('id'=>$type,'uniacid'=>$_SESSION['uniacid']),'type');
	$params['type']=$type;
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	if(isset($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_sort_item',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['url']=custom_url('jy_sort/item_detail//id='.$item['id'],true);
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	//招聘
	$htmls[1]=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'<red>[温馨提示]：置顶会随时失效（具体失效周期，移步：设置--置顶设置--后台置顶天数）</red>','edit'=>true,'list'=>array(
			array('name'=>'company_title','title'=>'公司名称','type'=>'string'),
			array('type'=>'string','title'=>'招聘岗位','name'=>'company_jobname'),
			array('name'=>'pay','title'=>'薪资','type'=>'radio','options'=>'pay'),
			array('name'=>'sex','title'=>'性别要求','type'=>'radio','options'=>'sex'),
			array('name'=>'looks','title'=>'浏览数量','type'=>'string'),
			array('name'=>'status','title'=>'是否启用','type'=>'switch','set'=>'set'),
			array('name'=>'url','title'=>'复制链接','type'=>'copy'),
			array('name'=>'url','title'=>'二维码','type'=>'ewm'),
			array('name'=>'ishot','title'=>'是否置顶','type'=>'radio','options'=>'ishot'),
		),'action'=>array(
			array('title'=>'置顶','type'=>'modal','op'=>'zhiding','action'=>'item_list','show'=>array('ishot'=>0)),
			array('title'=>'取消置顶','type'=>'post','op'=>'notop','action'=>'item_list','show'=>array('ishot'=>1)),
		)),
		'search'=>array(
			array('name'=>'company_title','title'=>'公司名称','type'=>'string','width'=>'15'),
			array('name'=>'status','title'=>'是否启用','type'=>'select','width'=>'15','options'=>'select_status'),
		)
	);
	$htmls[2]=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'<red>[温馨提示]：置顶会随时失效（具体失效周期，移步：设置--置顶设置--后台置顶天数）</red>','edit'=>true,'list'=>array(
			array('name'=>'name','title'=>'姓名','type'=>'string'),
			array('name'=>'age','title'=>'年龄','type'=>'string'),
			array('name'=>'educationid','title'=>'学历','type'=>'radio','options'=>'educationid'),
			array('name'=>'school','title'=>'学校','type'=>'string'),
			array('name'=>'timesid','title'=>'经验','type'=>'radio','options'=>'timesid'),
			array('name'=>'company_jobname','title'=>'求职岗位','type'=>'string'),
			array('name'=>'pay','title'=>'期望薪资','type'=>'string'),
			array('name'=>'sex','title'=>'性别','type'=>'radio','options'=>'sex'),
			array('name'=>'looks','title'=>'浏览数量','type'=>'string'),
			array('name'=>'status','title'=>'是否启用','type'=>'switch','set'=>'set'),
			array('name'=>'url','title'=>'复制链接','type'=>'copy'),
			array('name'=>'url','title'=>'二维码','type'=>'ewm'),
			array('name'=>'ishot','title'=>'是否置顶','type'=>'radio','options'=>'ishot'),
		),'action'=>array(
			array('title'=>'置顶','type'=>'modal','op'=>'zhiding','action'=>'item_list','show'=>array('ishot'=>0)),
			array('title'=>'取消置顶','type'=>'post','op'=>'notop','action'=>'item_list','show'=>array('ishot'=>1)),
		)),
		'search'=>array(
			array('name'=>'name','title'=>'姓名','type'=>'string','width'=>'15'),
			array('name'=>'status','title'=>'是否启用','type'=>'select','width'=>'15','options'=>'select_status'),
		)
	);
	$htmls[3]=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'<red>[温馨提示]：置顶会随时失效（具体失效周期，移步：设置--置顶设置--后台置顶天数）</red>','edit'=>true,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'isbuy','title'=>'类型','type'=>'radio','options'=>'isbuycar'),
			array('name'=>'lev','title'=>'车辆级别','type'=>'select','options'=>'lev'),
			array('name'=>'address','title'=>'地址','type'=>'string'),
			array('name'=>'looks','title'=>'浏览数量','type'=>'string'),
			array('name'=>'createtime','title'=>'发布时间','type'=>'time'),
			array('name'=>'status','title'=>'是否启用','type'=>'switch','set'=>'set'),
			array('name'=>'url','title'=>'复制链接','type'=>'copy'),
			array('name'=>'url','title'=>'二维码','type'=>'ewm'),
			array('name'=>'ishot','title'=>'是否置顶','type'=>'radio','options'=>'ishot'),
		),'action'=>array(
			array('title'=>'置顶','type'=>'modal','op'=>'zhiding','action'=>'item_list','show'=>array('ishot'=>0)),
			array('title'=>'取消置顶','type'=>'post','op'=>'notop','action'=>'item_list','show'=>array('ishot'=>1)),
		)),
		'search'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string','width'=>'15'),
			array('name'=>'status','title'=>'是否启用','type'=>'select','width'=>'15','options'=>'select_status'),
		)
	);
	$htmls[4]=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'<red>[温馨提示]：置顶会随时失效（具体失效周期，移步：设置--置顶设置--后台置顶天数）</red>','edit'=>true,'list'=>array(
			array('name'=>'name','title'=>'姓名','type'=>'string'),
			array('name'=>'age','title'=>'年纪','type'=>'string'),
			array('name'=>'sex','title'=>'性别','type'=>'radio','options'=>'sex'),
			array('name'=>'address','title'=>'地址','type'=>'string'),
			array('name'=>'looks','title'=>'浏览数量','type'=>'string'),
			array('name'=>'status','title'=>'是否启用','type'=>'switch','set'=>'set'),
			array('name'=>'url','title'=>'复制链接','type'=>'copy'),
			array('name'=>'url','title'=>'二维码','type'=>'ewm'),
			array('name'=>'ishot','title'=>'是否置顶','type'=>'radio','options'=>'ishot'),
		),'action'=>array(
			array('title'=>'置顶','type'=>'modal','op'=>'zhiding','action'=>'item_list','show'=>array('ishot'=>0)),
			array('title'=>'取消置顶','type'=>'post','op'=>'notop','action'=>'item_list','show'=>array('ishot'=>1)),
		)),
		'search'=>array(
			array('name'=>'name','title'=>'姓名','type'=>'string','width'=>'15'),
			array('name'=>'status','title'=>'是否启用','type'=>'select','width'=>'15','options'=>'select_status'),
		)
	);
	$htmls[5]=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'<red>[温馨提示]：置顶会随时失效（具体失效周期，移步：设置--置顶设置--后台置顶天数）</red>','edit'=>true,'list'=>array(
			array('name'=>'title','title'=>'物品名称','type'=>'string'),
			array('name'=>'price','title'=>'价格','type'=>'string'),
			array('name'=>'classifyid','title'=>'类型','type'=>'radio','options'=>'classifyid'),
			array('name'=>'looks','title'=>'浏览数量','type'=>'string'),
			array('name'=>'status','title'=>'是否启用','type'=>'switch','set'=>'set'),
			array('name'=>'url','title'=>'复制链接','type'=>'copy'),
			array('name'=>'url','title'=>'二维码','type'=>'ewm'),
			array('name'=>'ishot','title'=>'是否置顶','type'=>'radio','options'=>'ishot'),
		),'action'=>array(
			array('title'=>'置顶','type'=>'modal','op'=>'zhiding','action'=>'item_list','show'=>array('ishot'=>0)),
			array('title'=>'取消置顶','type'=>'post','op'=>'notop','action'=>'item_list','show'=>array('ishot'=>1)),
		)),
		'search'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string','width'=>'15'),
			array('name'=>'status','title'=>'是否启用','type'=>'select','width'=>'15','options'=>'select_status'),
		)
	);
	$htmls[6]=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'<red>[温馨提示]：置顶会随时失效（具体失效周期，移步：设置--置顶设置--后台置顶天数）</red>','edit'=>true,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'classifyid','title'=>'事件类型','type'=>'radio','options'=>'classifyid'),
			array('name'=>'name','title'=>'联系人姓名','type'=>'string'),
			array('name'=>'mobile','title'=>'联系人电话','type'=>'string'),
			array('name'=>'address','title'=>'地址','type'=>'string'),
			array('name'=>'looks','title'=>'浏览数量','type'=>'string'),
			array('name'=>'status','title'=>'是否启用','type'=>'switch','set'=>'set'),
			array('name'=>'url','title'=>'复制链接','type'=>'copy'),
			array('name'=>'url','title'=>'二维码','type'=>'ewm'),
			array('name'=>'ishot','title'=>'是否置顶','type'=>'radio','options'=>'ishot'),
		),'action'=>array(
			array('title'=>'置顶','type'=>'modal','op'=>'zhiding','action'=>'item_list','show'=>array('ishot'=>0)),
			array('title'=>'取消置顶','type'=>'post','op'=>'notop','action'=>'item_list','show'=>array('ishot'=>1)),
		)),
		'search'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string','width'=>'15'),
			array('name'=>'status','title'=>'是否启用','type'=>'select','width'=>'15','options'=>'select_status'),
		)
	);
	$htmls[7]=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'<red>[温馨提示]：置顶会随时失效（具体失效周期，移步：设置--置顶设置--后台置顶天数）</red>','edit'=>true,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'classifyid','title'=>'事件类型','type'=>'radio','options'=>'classifyid'),
			array('name'=>'name','title'=>'联系人姓名','type'=>'string'),
			array('name'=>'mobile','title'=>'联系人电话','type'=>'string'),
			array('name'=>'address','title'=>'地址','type'=>'string'),
			array('name'=>'looks','title'=>'浏览数量','type'=>'string'),
			array('name'=>'status','title'=>'是否启用','type'=>'switch','set'=>'set'),
			array('name'=>'url','title'=>'复制链接','type'=>'copy'),
			array('name'=>'url','title'=>'二维码','type'=>'ewm'),
			array('name'=>'ishot','title'=>'是否置顶','type'=>'radio','options'=>'ishot'),
		),'action'=>array(
			array('title'=>'置顶','type'=>'modal','op'=>'zhiding','action'=>'item_list','show'=>array('ishot'=>0)),
			array('title'=>'取消置顶','type'=>'post','op'=>'notop','action'=>'item_list','show'=>array('ishot'=>1)),
		)),
		'search'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string','width'=>'15'),
			array('name'=>'status','title'=>'是否启用','type'=>'select','width'=>'15','options'=>'select_status'),
		)
	);
	$htmls[8]=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'<red>[温馨提示]：置顶会随时失效（具体失效周期，移步：设置--置顶设置--后台置顶天数）</red>','edit'=>true,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'isbuy','title'=>'类型','type'=>'radio','options'=>'isbuy'),
			array('name'=>'address','title'=>'地址','type'=>'string'),
			array('name'=>'looks','title'=>'浏览数量','type'=>'string'),
			array('name'=>'createtime','title'=>'发布时间','type'=>'time'),
			array('name'=>'status','title'=>'是否启用','type'=>'switch','set'=>'set'),
			array('name'=>'url','title'=>'复制链接','type'=>'copy'),
			array('name'=>'url','title'=>'二维码','type'=>'ewm'),
			array('name'=>'ishot','title'=>'是否置顶','type'=>'radio','options'=>'ishot'),
		),'action'=>array(
			array('title'=>'置顶','type'=>'modal','op'=>'zhiding','action'=>'item_list','show'=>array('ishot'=>0)),
			array('title'=>'取消置顶','type'=>'post','op'=>'notop','action'=>'item_list','show'=>array('ishot'=>1)),
		)),
		'search'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string','width'=>'15'),
			array('name'=>'status','title'=>'是否启用','type'=>'select','width'=>'15','options'=>'select_status'),
		)
	);
	$htmls[9]=$htmls[0]=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'<red>[温馨提示]：置顶会随时失效（具体失效周期，移步：设置--置顶设置--后台置顶天数）</red>','edit'=>true,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'isbuy','title'=>'类型','type'=>'radio','options'=>'isbuy'),
			array('name'=>'address','title'=>'地址','type'=>'string'),
			array('name'=>'looks','title'=>'浏览数量','type'=>'string'),
			array('name'=>'createtime','title'=>'发布时间','type'=>'time'),
			array('name'=>'status','title'=>'是否启用','type'=>'switch','set'=>'set'),
			array('name'=>'url','title'=>'复制链接','type'=>'copy'),
			array('name'=>'url','title'=>'二维码','type'=>'ewm'),
			array('name'=>'ishot','title'=>'是否置顶','type'=>'radio','options'=>'ishot'),
		),'action'=>array(
			array('title'=>'置顶','type'=>'modal','op'=>'zhiding','action'=>'item_list','show'=>array('ishot'=>0)),
			array('title'=>'取消置顶','type'=>'post','op'=>'notop','action'=>'item_list','show'=>array('ishot'=>1)),
		)),
		'search'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string','width'=>'15'),
			array('name'=>'status','title'=>'是否启用','type'=>'select','width'=>'15','options'=>'select_status'),
		)
	);
	$return['select_status']=array(array('id'=>0,'title'=>'下架'),array('id'=>1,'title'=>'上架'));
	$return['htmls']=$htmls[$modetype];
	$return['ishot']=array('否','是');
	exi($return);
}
if($_RQ['op']=='edit'){
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('jy_sort_item',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		$item['images']=json_decode($item['images'],true);
		$item['tui_ids']=json_decode($item['tui_ids'],true);
		$item['lat_lng']=json_decode($item['lat_lng'],true);
	}else{
		$item=array();
	}
	$item['pcd']=array('province'=>$item['province'],'city'=>$item['city'],'district'=>$item['district']);
	$item['diyfileds']=json_decode($item['diyfileds'],true);
	if($item['diyfileds']){
		foreach($item['diyfileds'] as $k=>&$fv){
			if($fv['type']==5){
				$fv['data']=explode(';',$fv['data']);
				foreach($fv['data'] as $ki=>$vv){
					if(!$vv){
						unset($fv['data'][$ki]);
					}
				}
			}
		}
	}
	$return['item']=$item;
	$listitem[0]=$listitem[8]=$listitem[9]=array(					
					array('type'=>'string','title'=>'标题','name'=>'title','help'=>''),
					array('type'=>'text','title'=>'详情','name'=>'remark','help'=>''),
					array('type'=>'pcd','title'=>'地址','name'=>'pcd'),
					array('type'=>'string','title'=>'地址','name'=>'address'),
					array('type'=>'lat_lng','title'=>'坐标','name'=>'lat_lng'),
					array('name'=>'mid','title'=>'发布人','type'=>'choose','action'=>'core/member.get_member/'),
					array('type'=>'images','title'=>'多图','name'=>'images','help'=>''),
					//array('type'=>'checkbox','title'=>'上班时间','name'=>'work_time','help'=>'','options'=>'work_time'),
					array('name'=>'name','title'=>'联系人姓名','type'=>'string'),
					array('name'=>'mobile','title'=>'联系人电话','type'=>'string'),
					array('type'=>'string','title'=>'浏览量','name'=>'looks','help'=>''),
					array('type'=>'switch','title'=>'是否启用','name'=>'status','help'=>'设置是否启用'),
	);
	$listitem[1]=array(
					array('type'=>'string','title'=>'公司名称','name'=>'company_title','help'=>''),
					//array('type'=>'select','title'=>'所属项目分类','name'=>'type','options'=>'types'),
					//array('type'=>'string','title'=>'公司规模','name'=>'company_num','help'=>''),
					array('type'=>'string','title'=>'招聘岗位','name'=>'company_jobname'),
					array('type'=>'radio','title'=>'性别要求','name'=>'sex','help'=>'','options'=>'sex'),
					array('type'=>'text','title'=>'招聘详情','name'=>'remark','help'=>''),
					array('type'=>'radio','title'=>'薪资','name'=>'pay','help'=>'','options'=>'pay'),
					array('type'=>'pcd','title'=>'地址','name'=>'pcd'),
					array('type'=>'string','title'=>'详细地址','name'=>'address'),
					array('type'=>'lat_lng','title'=>'坐标','name'=>'lat_lng'),
				    array('name'=>'mid','title'=>'发布人','type'=>'choose','action'=>'core/member.get_member/'),
					array('type'=>'images','title'=>'多图','name'=>'images','help'=>''),
					//array('type'=>'checkbox','title'=>'上班时间','name'=>'work_time','help'=>'','options'=>'work_time'),
					array('name'=>'name','title'=>'联系人姓名','type'=>'string'),
					array('name'=>'mobile','title'=>'联系人电话','type'=>'string'),
					array('type'=>'string','title'=>'浏览量','name'=>'looks','help'=>''),
					array('type'=>'switch','title'=>'是否启用','name'=>'status','help'=>'设置是否启用'),
				);
	$listitem[2]=array(
					array('name'=>'name','title'=>'姓名','type'=>'string'),
					array('name'=>'age','title'=>'年龄','type'=>'string'),
					array('name'=>'educationid','title'=>'学历','type'=>'radio','options'=>'educationid'),
					array('name'=>'school','title'=>'学校','type'=>'string'),
					array('name'=>'timesid','title'=>'经验','type'=>'radio','options'=>'timesid'),
				//	array('name'=>'positionid','title'=>'求职岗位','type'=>'radio','options'=>'position'),
					array('name'=>'pay','title'=>'期望薪资','type'=>'string'),
					array('name'=>'sex','title'=>'性别','type'=>'radio','options'=>'sex'),
					array('name'=>'mid','title'=>'发布人','action'=>'core/member.get_member/','type'=>'choose'),
					array('name'=>'looks','title'=>'浏览数量','type'=>'string'),
					array('name'=>'status','title'=>'是否启用','type'=>'switch','set'=>'set'),
					array('name'=>'ishot','title'=>'是否热门','type'=>'switch','set'=>'set'),
				);
	$listitem[3]=array(
					array('type'=>'string','title'=>'标题','name'=>'title','help'=>''),
					array('name'=>'isbuy','title'=>'类型','type'=>'radio','options'=>'isbuycar'),
					array('type'=>'select','title'=>'车辆级别','name'=>'lev','help'=>'','options'=>'lev'),
					array('type'=>'text','title'=>'详情','name'=>'remark','help'=>''),
					array('type'=>'string','title'=>'价格','name'=>'price','help'=>''),
					array('type'=>'pcd','title'=>'地址','name'=>'pcd'),
					array('type'=>'string','title'=>'详细地址','name'=>'address'),
					array('type'=>'lat_lng','title'=>'坐标','name'=>'lat_lng'),
					array('name'=>'mid','title'=>'发布人','action'=>'core/member.get_member/','type'=>'choose'),
					array('type'=>'images','title'=>'多图','name'=>'images','help'=>''),
					//array('type'=>'checkbox','title'=>'上班时间','name'=>'work_time','help'=>'','options'=>'work_time'),
					array('name'=>'name','title'=>'联系人姓名','type'=>'string'),
					array('name'=>'mobile','title'=>'联系人电话','type'=>'string'),
					array('type'=>'string','title'=>'浏览量','name'=>'looks','help'=>''),
					array('type'=>'switch','title'=>'是否启用','name'=>'status','help'=>'设置是否启用'),
					array('type'=>'switch','title'=>'是否热门','name'=>'ishot','help'=>''),
				);
	$listitem[4]=array(
					array('type'=>'string','title'=>'姓名','name'=>'name','help'=>''),
					array('type'=>'string','title'=>'联系电话','name'=>'mobile','help'=>''),
					array('type'=>'string','title'=>'微信','name'=>'weixin','help'=>''),
					array('type'=>'string','title'=>'年龄','name'=>'age','help'=>''),
					array('name'=>'sex','title'=>'性别','type'=>'radio','options'=>'sex'),
					array('type'=>'text','title'=>'个人介绍','name'=>'remark','help'=>''),
					array('type'=>'pcd','title'=>'地址','name'=>'pcd'),
					array('type'=>'string','title'=>'详细地址','name'=>'address'),
					array('type'=>'lat_lng','title'=>'坐标','name'=>'lat_lng'),
					array('name'=>'mid','title'=>'发布人','action'=>'core/member.get_member/','type'=>'choose'),
					array('type'=>'images','title'=>'多图','name'=>'images','help'=>''),
					//array('type'=>'checkbox','title'=>'上班时间','name'=>'work_time','help'=>'','options'=>'work_time'),
					array('type'=>'string','title'=>'浏览量','name'=>'looks','help'=>''),
					array('type'=>'switch','title'=>'是否启用','name'=>'status','help'=>'设置是否启用'),
				);
	$listitem[5]=array(
					array('type'=>'string','title'=>'物品名称','name'=>'title','help'=>''),
					array('type'=>'radio','title'=>'类型','name'=>'classifyid','help'=>'','options'=>'classifyid'),
					array('type'=>'text','title'=>'详情','name'=>'remark','help'=>''),
					array('type'=>'string','title'=>'价格','name'=>'price','help'=>''),
					array('type'=>'pcd','title'=>'地址','name'=>'pcd'),
					array('type'=>'string','title'=>'详细地址','name'=>'address'),
					array('type'=>'lat_lng','title'=>'坐标','name'=>'lat_lng'),
					array('name'=>'mid','title'=>'发布人','action'=>'core/member.get_member/','type'=>'choose'),
					array('type'=>'images','title'=>'多图','name'=>'images','help'=>''),
					//array('type'=>'checkbox','title'=>'上班时间','name'=>'work_time','help'=>'','options'=>'work_time'),
					array('name'=>'name','title'=>'联系人姓名','type'=>'string'),
					array('name'=>'mobile','title'=>'联系人电话','type'=>'string'),
					array('type'=>'string','title'=>'浏览量','name'=>'looks','help'=>''),
					array('type'=>'switch','title'=>'是否启用','name'=>'status','help'=>'设置是否启用'),
				);
	$listitem[6]=array(
					array('type'=>'string','title'=>'标题','name'=>'title','help'=>''),
					array('name'=>'classifyid','title'=>'事件类型','type'=>'radio','options'=>'classifyid'),
					array('type'=>'text','title'=>'详情','name'=>'remark','help'=>''),
					array('type'=>'pcd','title'=>'地址','name'=>'pcd'),
					array('type'=>'string','title'=>'详细地址','name'=>'address'),
					array('type'=>'lat_lng','title'=>'坐标','name'=>'lat_lng'),
					array('type'=>'string','title'=>'地址','name'=>'address'),
					array('name'=>'mid','title'=>'发布人','type'=>'choose','action'=>'core/member.get_member/'),
					array('type'=>'images','title'=>'多图','name'=>'images','help'=>''),
					//array('type'=>'checkbox','title'=>'上班时间','name'=>'work_time','help'=>'','options'=>'work_time'),
					array('name'=>'name','title'=>'联系人姓名','type'=>'string'),
					array('name'=>'mobile','title'=>'联系人电话','type'=>'string'),
					array('type'=>'string','title'=>'浏览量','name'=>'looks','help'=>''),
					array('type'=>'switch','title'=>'是否启用','name'=>'status','help'=>'设置是否启用'),
				);
	$listitem[7]=array(
					array('type'=>'string','title'=>'标题','name'=>'title','help'=>''),
					array('type'=>'radio','title'=>'类型','name'=>'isbuy','help'=>'','options'=>'isbuy'),
					array('type'=>'text','title'=>'详情','name'=>'remark','help'=>''),
					array('type'=>'pcd','title'=>'地址','name'=>'pcd'),
					array('type'=>'string','title'=>'详细地址','name'=>'address'),
					array('type'=>'lat_lng','title'=>'坐标','name'=>'lat_lng'),
					array('name'=>'mid','title'=>'发布人','action'=>'core/member.get_member/','type'=>'choose'),
					array('type'=>'images','title'=>'多图','name'=>'images','help'=>''),
					//array('type'=>'checkbox','title'=>'上班时间','name'=>'work_time','help'=>'','options'=>'work_time'),
					array('name'=>'name','title'=>'联系人姓名','type'=>'string'),
					array('name'=>'mobile','title'=>'联系人电话','type'=>'string'),
					array('type'=>'string','title'=>'浏览量','name'=>'looks','help'=>''),
					array('type'=>'switch','title'=>'是否启用','name'=>'status','help'=>'设置是否启用'),
				);
	$modetype=pdo_getcolumn('jy_sort_item_type',array('id'=>$this->session('type'),'uniacid'=>$_SESSION['uniacid']),'type');
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'tabs'=>array(
			array('op'=>'list','title'=>'返回信息列表'),
		),
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基本信息',
				'list'=>$listitem[$modetype]
			),
			array(
				'title'=>'关联推送',
					'list'=>array(
						array('type'=>'choose_many','action'=>'jy_sort/item_list/choose_items/imgtitle=1','name'=>'tui_ids','title'=>'选择要关联的信息'),
					)
			),
		)
	);
	if($item['diyfileds']){
		foreach($item['diyfileds'] as $k=>&$dv){
			$htmls['edits'][0]['list'][]=array(
				'read'=>true,
				'type'=>'string',
				'title'=>$dv['title'],
				'name'=>'diyfileds['.$k.'].data',
			);
		}	
	}
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='post'){
	$modetype=pdo_getcolumn('jy_sort_item_type',array('type'=>$this->session('type'),'uniacid'=>$_SESSION['uniacid']),'type');
	$postdata=get_postdata();
	if(!$postdata['pcd']['province']){
			exi('城市不能为空！','error');
	}
	if($modetype!=1 && !$postdata['title']){
			exi('标题不能为空！','error');
	}
	if(!$postdata['remark']){
			exi('说明不能为空！','error');
	}
	if(!$postdata['name']){
			exi('联系人姓名不能为空！','error');
	}
	if(empty($postdata['lat_lng'])){
			//exi('请选择坐标！','error');
	}
	if($modetype==1 && !$postdata['company_jobname']){
			exi('招牌岗位不能为空！','error');
	}
	if($postdata['pcd']){
		if($postdata['pcd']['city']){
			if($postdata['pcd']['city']=='北京市' || $postdata['pcd']['city']=='上海市' || $postdata['pcd']['city']=='天津市'){
				$address=$postdata['pcd']['city'].' 市辖区';
			}else{
				$address=$postdata['pcd']['province'].' '.$postdata['pcd']['city'];
			}
			$code=pdo_getcolumn('core_area',array('address'=>$address),'parent_code');
		}
	}
	$data=array(
		'title'=>trim($postdata['title']),
		'images'=>ijson_encode($postdata['images']),
		'mid'=>intval($postdata['mid']),
		'remark'=>trim($postdata['remark']),
		'name'=>trim($postdata['name']),
		'mobile'=>trim($postdata['mobile']),
		'address'=>trim($postdata['address']),
		'status'=>intval($postdata['status']),
		'province'=>$postdata['pcd']['province'],
		'city'=>$postdata['pcd']['city'],
		'district'=>$postdata['pcd']['district'],
		'code'=>$code,
		'looks'=>intval($postdata['looks']),
		'ishot'=>intval($postdata['ishot']),
		'tui_ids'=>ijson_encode($postdata['tui_ids']),
		'lat_lng'=>ijson_encode($postdata['lat_lng']),
		'sex'=>intval($postdata['sex']),
		'company_title'=>trim($postdata['company_title']),
		'company_jobname'=>trim($postdata['company_jobname']),
		'company_num'=>intval($postdata['company_num']),
		'age'=>intval($postdata['age']),
		'timesid'=>intval($postdata['timesid']),
		'educationid'=>intval($postdata['educationid']),
		'pay'=>intval($postdata['pay']),
		'lev'=>intval($postdata['lev']),
		'price'=>trim($postdata['price']),
		'weixin'=>trim($postdata['weixin']),
		'classifyid'=>intval($postdata['classifyid']),
	);
	$id=intval($postdata['id']);
	if($id){
		pdo_update('jy_sort_item',$data,array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}else{
		$data['uniacid']=$_SESSION['uniacid'];
		$data['type']=$this->session('type');
		if(!$data['type']){
			exi('还没有绑定相关的项目！','error');
		}
		pdo_insert('jy_sort_item',$data);
	}
	exi('操作成功！','','list');
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_sort_item',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
if($_RQ['op']=='set'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择要编辑的事件！','error');
	}
	$post=get_postdata();
	if(isset($post['status'])){
		pdo_update('jy_sort_item',array('status'=>intval($post['status'])),array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}
	if(isset($post['ishot'])){
		$basic=$this->plugin_setting('basic');
		$topdays=intval($basic['topdays'])?:7;
		$topendtime=TIMESTAMP+$topdays*24*3600;
		pdo_update('jy_sort_item',array('ishot'=>intval($post['ishot']),'topendtime'=>$topendtime),array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}
	exi('操作成功！');
}
if($_RQ['op']=='zhiding'){
	$basic=$this->plugin_setting('basic');
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=intval($post['id']);
		if(!$id){
			exi('参数错误！','error');
		}
		if($post['packnum']<1){
			exi('置顶数必须大于1！','error');
		}
		if(intval($post['iskou'])){
			$packnum=$post['packnum'];
			$packname=$post['packname'];
			if($packname==1){
				if(!$basic['topfeeday']){
					exi('还未设置按天数置顶费用，移步参数设置--置顶设置！','error');
				}
				$fee=$basic['topfeeday']*$packnum;
				$packtitle='天';
			}elseif($packname==2){
				if(!$basic['topfeeyue']){
					exi('还未设置按月数置顶费用，移步参数设置--置顶设置！','error');
				}
				$fee=$basic['topfeeyue']*$packnum;
				$packtitle='月';
			}elseif($packname==3){
				if(!$basic['topfeeji']){
					exi('还未设置按季数置顶费用，移步参数设置--置顶设置！','error');
				}
				$fee=$basic['topfeeji']*$packnum;
				$packtitle='季';
			}
			$title='置顶帖子收费：'.$packnum.'《'.$packtitle.'》';
			$jianfee=model('core/member')->cut_credit2($post['mid'],$fee,$title,'jy_sort');
			if(!$jianfee){
				exi('客户余额不够，付费置顶失败！','error');
			}
			if($packname==3){
				$packnum2=$packnum*120;
			}elseif($packname==2){
				$packnum2=$packnum*30;
			}else{
				$packnum2=$packnum;
			}
			if($item['topendtime']<TIMESTAMP){	
				$topendtime=TIMESTAMP+$packnum2*24*3600;
			}else{
				$topendtime =$item['topendtime']+$packnum2*24*3600;
			}
			$insert=array(
				'uniacid'=>$_SESSION['uniacid'],
				'mid'=>$post['mid'],
				'packname'=>$packname,
				'packnum'=>$packnum,
				'ordersn'=>get_ordersn('jy_sort_fabulog','ordersn'),
				'type'=>$post['type'],
				'title'=>$title,
				'itemid'=>$post['id'],
				'fee'=>$fee,
				'createtime'=>TIMESTAMP,
				'ispay'=>1
			);
			pdo_insert('jy_sort_fabulog',$insert);
			$id=pdo_insertid();
		}else{
			$topdays=intval($basic['topdays'])?:7;
			$topendtime=TIMESTAMP+$topdays*24*3600;
		}
		pdo_update('jy_sort_item',array('ishot'=>1,'topendtime'=>$topendtime),array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));	
		exi('操作成功！','','list');
	}
	$id=intval($_RQ['id']);
	$item=$this->pdo_get('item',array('id'=>$id),array('id','mid','ishot','type'));
	$item['packnum']=intval($basic['packnum'])?:7;
	$htmls=array(
		'type'=>'edit',
		'desc'=>'置顶设置',
	);
	$htmls['edit']=array(
		array('type'=>'switch','title'=>'是否扣费','name'=>'iskou','help'=>'如果扣费的话，回自动扣除该主题的发布者相应的置顶费用'),
		array('type'=>'radio','title'=>'置顶方式','name'=>'packname','options'=>'packnames','show'=>array('iskou'=>1)),
		array('type'=>'unitstring','title'=>'置顶天数','name'=>'packnum','unit'=>'天（'.$basic['topfeeday'].'/天）','show'=>array('packname <='=>1)),
		array('type'=>'unitstring','title'=>'置顶月数','name'=>'packnum','unit'=>'月（'.$basic['topfeeyue'].'/月）','show'=>array('packname'=>2)),
		array('type'=>'unitstring','title'=>'置顶季数','name'=>'packnum','unit'=>'季（'.$basic['topfeeji'].'/季）','show'=>array('packname'=>3)),
	);
	$return['htmls']=$htmls;
	$return['item']=$item;
	$return['packnames']=array(1=>'按天付费',2=>'按月支付',3=>'按季支付');
	exi($return);
}
if($_RQ['op']=='choose_items'){
	$params=array(
		'uniacid'=>$_SESSION['uniacid'],
		'status'=>1,
	);
	if(trim($_RQ['keyword'])){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
		$return['params']['keyword']=trim($_RQ['keyword']);
	}
	if(intval($_RQ['pid'])){
		$params['type']=intval($_RQ['pid']);
		$return['params']['type']=intval($_RQ['pid']);
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	if(intval($_RQ['num'])){
		$psize=intval($_RQ['num']);
	}
	$total='';
	$fields=array('id','title','images','mid','type','price','looks','lat_lng');
	$orderby='id desc ';
	$list=pdo_getslice('jy_sort_item',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	if($list){
		foreach($list as &$item){
			//整理返回数据
			if($_RQ['imgtitle']=='1'){
				$item['res']=array('id'=>$item['id'],'title'=>$item['title']);
			}else{
				$item['res']=$item['id'];
			}
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['htmls']=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'信息列表'),
		),
		'list'=>array('data'=>'list','del_one'=>false,'delall'=>false,'edit'=>false,'list'=>array(
		    array('name'=>'id','title'=>'是否启用','type'=>'string'),
			array('name'=>'ishot','title'=>'是否置顶','type'=>'radio','options'=>'ishots'),
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'looks','title'=>'浏览数量','type'=>'string'),	
		),'action'=>array(
			array('type'=>'modal_result','name'=>'res','title_field'=>'title','title'=>'选取'),
		)),
		'search'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string','width'=>'15'),
			array('name'=>'type','title'=>'分类','type'=>'select','width'=>'15','options'=>'groups'),
		)
	);
	$return['ishots']=array('否','是');
	$return['groups']=pdo_getall('jy_sort_item_type',array('uniacid'=>$_SESSION['uniacid'],'status'=>1),'id');
	exi($return);
}
if($_RQ['op']=='notop'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择要编辑的事件！','error');
	}
	pdo_update('jy_sort_item',array('ishot'=>0),array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	exi('取消置顶成功！');
}